import { DataListParams, DeleteParams, ResultModel, AEParams } from './model/model'
import { useGlobSetting } from '/@/hooks/setting'
// import { useGlobSetting } from '/@/hooks/setting'
import { defHttp } from '/@/utils/http/axios'
import { ErrorMessageMode, UploadFileParams } from '/@/utils/http/axios/types'

// 方案模板api
enum Api {
    // 案例
    dataListUrl = '/articles/list',
    dataItemUrl = '/articles/info',
    deleteUrl = '/articles/delete',
    addUrl = '/articles/add',
    editUrl = '/articles/edit',
}

/**
 * @description: 列表
 */
export function dataListApi(params: DataListParams, mode: ErrorMessageMode = 'modal') {
    return defHttp.request<ResultModel>(
        {
            url: Api.dataListUrl,
            method: 'POST',
            params,
        },
        {
            errorMessageMode: mode,
        }
    )
}

/**
 * @description: 详情
 */
export function dataItemApi(params: DeleteParams, mode: ErrorMessageMode = 'modal') {
    return defHttp.request(
        {
            url: Api.dataItemUrl,
            method: 'POST',
            params,
        },
        {
            errorMessageMode: mode,
        }
    )
}

/**
 * @description: 删除
 */
export function deleteApi(params: DeleteParams, mode: ErrorMessageMode = 'modal') {
    return defHttp.request(
        {
            url: Api.deleteUrl,
            method: 'POST',
            params,
        },
        {
            errorMessageMode: mode,
        }
    )
}

/**
 * @description: 更新
 */

export function updateApi(params: AEParams, mode: ErrorMessageMode = 'modal') {
    return defHttp.request(
        {
            url: Api.editUrl,
            method: 'POST',
            params,
        },
        {
            errorMessageMode: mode,
        }
    )
}
/**
 * @description: 添加
 */
export function addApi(params: AEParams, mode: ErrorMessageMode = 'modal') {
    return defHttp.request(
        {
            url: Api.addUrl,
            method: 'POST',
            params,
        },
        {
            errorMessageMode: mode,
        }
    )
}
